#pragma once
#include "SehnsuchtPrecompiled.hxx"
#include "SehnsuchtArray.hxx"

namespace Sehnsucht { namespace IO
{
	ref_class_decl BasicReaderWriter
	{
	public_shared_access:
	#ifdef REIGN_DESKTOP // Desktop
		typedef std::shared_ptr<const Sehnsucht::Array<Byte>> ByteArrayConstPtr;
		typedef std::shared_ptr<Sehnsucht::Array<Byte>> ByteArrayPtr;
		typedef Reign::Standard::String16 StringArg; TinyTypeDecl( StringArg );
		typedef String16ConstRef FolderArg; // Path 
	#else // HERZELEID_DESKTOP (BOTH 32 AND 64)
		typedef const Platform::Array<Byte>^ ByteArrayConstPtr;
		typedef Platform::Array<Byte>^ ByteArrayPtr;
		typedef Windows::Storage::StorageFolder^ FolderArg; // Folder type 
		typedef Platform::String^ StringArg;
	#endif // HERZELEID_METRO || HERZELEID_PHONE

		typedef Concurrency::task<ByteArrayPtr> AsyncByteArrayPtr;
		typedef Concurrency::task<UInt32> AsyncUInt32;
		typedef Concurrency::task<Void> AsyncAction;

	owned_access:

	#ifdef REIGN_DESKTOP
		String16 m_LocationPath;
	#else // HERZELEID_DESKTOP (BOTH 32 AND 64)
		FolderArg m_Folder; // Folder wrapper 
		StringArg m_Path; // Folder path 
	#endif // HERZELEID_METRO || HERZELEID_PHONE

	public_owned_access:

		// DESKTOP: Creates/opens the Herzelied directory in personal folder. 
		// OTHER: Opens the package install folder. Throws on failure. 
		BasicReaderWriter();

		// Throws on failure. 
		BasicReaderWriter( _In_ FolderArg Folder );

		// Throws on failure. 
		_Outptr_result_nullonfailure_ ByteArrayPtr ReadData( 
			_In_ StringArg FileName 
			);

		// Throws on failure. 
		_Outptr_result_nullonfailure_ AsyncByteArrayPtr ReadDataAsync( 
			_In_ StringArg FileName 
			);

		// Throws on failure. 
		UInt32 WriteData( 
			_In_ StringArg FileName, 
			_In_ ByteArrayConstPtr Data 
			);

		// Throws on failure. 
		AsyncUInt32 WriteDataAsync( 
			_In_ StringArg FileName, 
			_In_ ByteArrayConstPtr Data 
			);

	}; // BasicReaderWriter

}; };